package com.kaishengit.service;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.kaishengit.dao.TagDao;
import com.kaishengit.pojo.Contact;
import com.kaishengit.pojo.Tag;
import com.kaishengit.pojo.User;
@Service
@Transactional
public class TagService {
	
	private ContactService contactService;
	private TagDao tagDao;
	
	public void saveTag(String name,String tag, User user) {
		Contact conta =contactService.findByContactName(name);
		System.out.println(name);
		System.out.println(tag);
		Tag tags = new Tag();
		
		
		List<Contact> lc = new ArrayList<Contact>();
		lc.add(conta);
		tags.setName(tag);
		tags.setContactList(lc);
		tags.setUser(user);
		
		tagDao.save(tags);
		System.out.println(tags.getId());
	}

	
	@Autowired
	public void setContactService(ContactService contactService) {
		this.contactService = contactService;
	}

	@Autowired
	public void setTagDao(TagDao tagDao) {
		this.tagDao = tagDao;
	}
	
}
